package com.arm.service.impl;

import com.arm.dao.PaymentMapper;
import com.arm.module.Payment;
import com.arm.service.BaseService;
import com.arm.service.PaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by Baggio on 2019-1-8.
 */
@Service
public class PaymentServiceImpl extends BaseService implements PaymentService {
    @Autowired
    PaymentMapper paymentMapper;

    @Override
    public void insertPayment(Payment payment) {
        paymentMapper.insertPayment(payment);
    }

    @Override
    public Payment getPaymentByOrderId(Long orderId) {
        return paymentMapper.selectByOrderId(orderId);
    }

    @Override
    public void modifyPayment(Payment payment) {
        if (payment.getTid() == null) {
            paymentMapper.insertPayment(payment);
            return;
        }
        paymentMapper.updatePaymentById(payment);
    }

    @Override
    public List<Payment> selectpaymentListByOrderId(Map<String, String> map) {
        return paymentMapper.selectpaymentListByOrderId(map);
    }
}
